package HashMap的7种遍历方式;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class One {
    //迭代器（Iterator）EntrySet方式
    public static void main(String[] args) {
        Map<Integer, String> map = new HashMap<>();
        map.put(1,"Java");
        map.put(2,"C++");
        map.put(3,"C");
        map.put(4,"Python");
        map.put(5,"Golang");

        //遍历
        Iterator<Map.Entry<Integer, String>> iterator = map.entrySet().iterator();
        while(iterator.hasNext()) {
            Map.Entry<Integer, String> entry = iterator.next();
            System.out.println(entry.getKey());
            System.out.println(entry.getValue());
        }
    }
}
